<template>
  <div class="container">
    <div v-show="isAuthorHome">
      <div class="media-box">
        <img  class="media-img" :src="media.media_image">
        <label class="media-name">{{media.media_name}}</label>
        <div class="media-intro">{{String(media.media_intro).slice(0,60)}}</div>
      </div>
      <div class="container">
        <router-link :to="`/author/forecastdetail/${item.id}?index=${index}`" class="fore-cell"  v-for="(item, index) in forecastList" :key="item.id">
          <label class="fore-title">{{item.title}}</label>
          <div class="fore-time">{{ dateFormat(item.create_time)}}</div>
        </router-link>
        <!-- <div class="fore-cell">
          <text style="font-size:24rpx;line-height:40rpx;">仅展示近10天数据，完整数据之后可在公众号“椰子观点”看到</text>
        </div> -->
      </div>
    </div>
    <transition>
      <router-view />
    </transition>
  </div>

</template>
<style src="../style/author.less" scoped></style>
<script>
export default {
  data () {
    return {
      media: {},
      forecastList: []
    }
  },
  created () {
    // 获取媒体号信息
    this.getMediaInfo()

    // 获取媒体号预测信息列表
    this.getForecastListByMediaId()
  },
  computed: {
    isAuthorHome: function () {
      return this.$store.state.isAuthorHome
    }
  },
  methods: {
     // 媒体号信息
    async getMediaInfo () {
      const media = await this.$parent.util.requestApi('/lottery/api/v1/get_media_info_by_id', 'get', `media_id=${this.$route.query.mediaId}`)

      this.media = media
    },
    async getForecastListByMediaId () {
      let forecastList = await this.$parent.util.requestApi('/lottery/api/v1/get_forecast_list_by_media_id', 'get', `mediaId=${this.$route.query.mediaId}`)

      this.forecastList = forecastList
    },
    dateFormat (t) {
      return this.$parent.util.dateFormat(t)
    }
  }
}
</script>
